Skip to content

fix: improve multi-column rendering#2369

Open
VladaHarbour wants to merge 6 commits intomainfrom
sd-2008_multi-column-bug
Open

fix: improve multi-column rendering#2369
VladaHarbour wants to merge 6 commits intomainfrom
sd-2008_multi-column-bug

Conversation

@VladaHarbour
Copy link
Contributor

Initial issue:
SuperDoc does not match Word layout for early pages in a document that combines:

  1. Continuous section breaks.
  2. A manual column break before the first custom two-column section.
  3. An asymmetric first two-column setup.
Screen Shot 2026-02-25 at 1 30 05 PM

@linear
Copy link

linear bot commented Mar 11, 2026

caio-pizzol

This comment was marked as outdated.

@caio-pizzol caio-pizzol self-requested a review March 11, 2026 21:24
Copy link
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladaHarbour looks good overall. left a few small inline comments.

one test comment at column-balancing.test.ts:293 describes a check that doesn't exist — easy fix.

normalizeColumnsForFootnotes and normalizeColumns are mostly the same ~30 lines — a shared helper would keep them in sync.

on tests: widthsEqual and cloneColumnLayout have a few branches but no unit tests. also nothing covers the case where two sections share count/gap but differ only in widths or equalWidth.

@@ -128,12 +129,40 @@ const COLUMN_EPSILON = 0.01;
type NormalizedColumns = ColumnLayout & { width: number };
type PageColumns = NormalizedColumns & { left: number; contentWidth: number };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is almost copy-pasted from normalizeColumns in index.ts:2567. could they share one helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created shared helper

type NormalizedColumns = ColumnLayout & { width: number };
type PageColumns = NormalizedColumns & { left: number; contentWidth: number };

const resolveMaxColumnWidth = (contentWidth: number, columns?: ColumnLayout): number => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

footnotes are always measured using the widest column's width. if a footnote lands in a narrower column, its wrapping might be slightly off. maybe add a // TODO so it doesn't catch someone off guard later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants